const mongoose = require('mongoose')
const { dbUri } = require('../config/config.default')

mongoose.connect(dbUri, {
  useNewUrlParser: true,
  useUnifiedTopology: true,
})

const db = mongoose.connection

db.on('error', (err) => {
  console.log('err', err)
})

db.once('open', () => {
  console.log('MongoDb connect is success~')
})

module.exports = {
  User: mongoose.model('User', require('./user')),
}
